<%@page language="C#" Debug="true" %>
<%@import namespace="System.Collections.Generic" %>
<%@import namespace="System.Data" %>
<%@import namespace="My.Data" %>
<%@import namespace="My.Data.Worker" %>



<script runat="server">

    protected void Page_Load( object sender, System.EventArgs e )
    {
				Tools t = new Tools();
				t.RepairProductCatalog();
    }
    
    
    public class Tools
    {
    		private DB _db = new DB(  ConfigurationManager.ConnectionStrings["gzglhouse"].ConnectionString.ToString()  );
    		private Product product = new Product();
    		
    		// int RepairNode( string id )
    		public void RepairProductCatalog()
    		{
    				if( "RepairProductCatalog" != HttpContext.Current.Request["cmd"] ){ return;  }
    				
    				string sql = "Select id,parentId From Gl_Pro_Catalog";
    				DataTable table = _db.Select( sql );
    				
    				DataRow row;
    				for( int i=0; i<table.Rows.Count; i++ )
    				{
    						row = table.Rows[i];
    						try
    						{
    								product.Catalog.RepairNode( row["id"].ToString() );
    								product.Catalog.SetToIdOrder( (int)row["parentId"], "" );
    								HttpContext.Current.Response.Write( row["id"].ToString() + "成功!<br />" );
    						}
    						catch( Exception e )
    						{
    								HttpContext.Current.Response.Write( e.Message + "<br />" );
    						}
    				}
    		}
    }
</script>


